#============================================================
#	PlayerAttack
#============================================================
# @datetime: 2022-4-26 00:59:06
#============================================================
class_name PlayerAttack
extends PlayerBaseState


var _attack : BaseSkill


#============================================================
#   内置
#============================================================
func _enter_tree():
	_attack = $Attack
	_attack.connect("ready_execute", self, "_ready_execute")
	_attack.connect("execute_duration", self, "_executed")
	_attack.connect("execute_finished", self, "_execute_finished")
	set_data("Attack", _attack)


#============================================================
#   状态
#============================================================
#(override)
func enter():
	_attack.start()


#(override)
func state_process(_arg0):
	input_move()


#============================================================
#   连接信号
#============================================================
# 准备攻击
func _ready_execute():
	get_blackboard().get_move_controller().move_enabled = false

# 发出攻击
func _executed():
	get_blackboard().get_move_controller().move_enabled = true

# 攻击完成
func _execute_finished():
	if input_jump():
		switch_to(PlayerStateBlackboard.States.JUMP)
	elif get_blackboard().is_moving():
		switch_to(PlayerStateBlackboard.States.MOVE)
	else:
		switch_to(PlayerStateBlackboard.States.IDLE)


